import request from "@/utils/request";
import { skuInfoData, SkuResponseData } from "./type";

// SKU管理模块接口

enum API {
  // 获取已有商品的数据
  SKU_URL = '/admin/product/list/',
  // 上架
  SALE_URL = '/admin/product/onSale/',
  // 下架
  CANCELSALE_URL = '/admin/product/cancelSale/',
  // 获取商品详情的接口
  SKUINFO_URL = '/admin/product/getSkuInfo/',
  // 删除已有的商品
  DELETESKU_URL = '/admin/product/deleteSku/'
}

// 获取商品SKU接口
export const reqSkuList = (page: number, limit: number) => request.get<any, SkuResponseData>(API.SKU_URL + `${page}/${limit}`)
// 已有商品上架的接口
export const reqSaleSku = (skuId: number) => request.get<any, any>(API.SALE_URL + skuId)
// 下架接口
export const reqCancelSku = (skuId: number) => request.get<any, any>(API.CANCELSALE_URL + skuId)
// 获取商品详情的接口
export const reqSkuInfo = (skuId: number) => request.get<any, skuInfoData>(API.SKUINFO_URL + skuId)
// 删除已有商品
export const reqRemoveSku = (skuId: number) => request.delete<any, any>(API.DELETESKU_URL + skuId)